#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int drink(int m)
{
	float pin = 0;
	while ((int)m)
	{
		pin += m;
		if (m % 2)
		{
			pin += 0.5;
			m -= 1;
		}
		m /= 2;
	}
	return (int)pin;
}

int main()
{
	int money = 0;
	scanf("%d", &money);
	printf("%d\n", drink(money));
	return 0;
}
